<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/limh/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/limh/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/limh/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/limh/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/limh/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/limh/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/limh/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="教程,">










<meta name="description" content="上下移动我们会了，那我们还想左右移动该如何操作呢？ 方法一、最简单，就是把板子侧过来放，纵向取模就可以完成。 这里大家是不是有种头顶冒汗的感觉？我们要做好技术，但是不能沉溺于技术。技术是我们的工具，我们在做开发的时候除了用好这个工具外，也得多拓展自己解决问题的思路，要慢慢培养自己的多角度思维方式。 那把板子正过来，左右移动就完不成了吗？当然不是。大家慢慢的学多了就会培养了一种感觉，就是一旦硬件设计">
<meta name="keywords" content="教程">
<meta property="og:type" content="article">
<meta property="og:title" content="7.6、LED点阵的横向移动">
<meta property="og:url" content="https://tdnr.gitee.io/limh/2014/12/01/mcu047/index.html">
<meta property="og:site_name" content="土逗牛肉">
<meta property="og:description" content="上下移动我们会了，那我们还想左右移动该如何操作呢？ 方法一、最简单，就是把板子侧过来放，纵向取模就可以完成。 这里大家是不是有种头顶冒汗的感觉？我们要做好技术，但是不能沉溺于技术。技术是我们的工具，我们在做开发的时候除了用好这个工具外，也得多拓展自己解决问题的思路，要慢慢培养自己的多角度思维方式。 那把板子正过来，左右移动就完不成了吗？当然不是。大家慢慢的学多了就会培养了一种感觉，就是一旦硬件设计">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://c.biancheng.net/cpp/uploads/allimg/140317/1-14031F13303M5.png">
<meta property="og:updated_time" content="2019-01-27T07:12:52.615Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="7.6、LED点阵的横向移动">
<meta name="twitter:description" content="上下移动我们会了，那我们还想左右移动该如何操作呢？ 方法一、最简单，就是把板子侧过来放，纵向取模就可以完成。 这里大家是不是有种头顶冒汗的感觉？我们要做好技术，但是不能沉溺于技术。技术是我们的工具，我们在做开发的时候除了用好这个工具外，也得多拓展自己解决问题的思路，要慢慢培养自己的多角度思维方式。 那把板子正过来，左右移动就完不成了吗？当然不是。大家慢慢的学多了就会培养了一种感觉，就是一旦硬件设计">
<meta name="twitter:image" content="http://c.biancheng.net/cpp/uploads/allimg/140317/1-14031F13303M5.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/limh/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://tdnr.gitee.io/limh/2014/12/01/mcu047/">





  <title>7.6、LED点阵的横向移动 | 土逗牛肉</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans ">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/limh/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">土逗牛肉</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/limh/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/limh/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/limh/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/limh/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/limh/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://tdnr.gitee.io/limh/limh/2014/12/01/mcu047/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="土逗牛肉">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/limh/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="土逗牛肉">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">7.6、LED点阵的横向移动</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2014-12-01T20:36:30+08:00">
                2014-12-01
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/limh/categories/单片机教程/" itemprop="url" rel="index">
                    <span itemprop="name">单片机教程</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>上下移动我们会了，那我们还想左右移动该如何操作呢？</p>
<p><strong>方法一、最简单，就是把板子侧过来放，纵向取模就可以完成。</strong></p>
<p>这里大家是不是有种头顶冒汗的感觉？我们要做好技术，但是不能沉溺于技术。技术是我们的工具，我们在做开发的时候除了用好这个工具外，也得多拓展自己解决问题的思路，要慢慢培养自己的多角度思维方式。</p>
<p>那把板子正过来，左右移动就完不成了吗？当然不是。大家慢慢的学多了就会培养了一种感觉，就是一旦硬件设计好了，我们要完成一种功能，大脑就可以直接思考出来能否完成这个功能，这个在我们进行电路设计的时候最为重要。我们在开发产品的时候，首先是设计电路，设计电路的时候，工程师就要在大脑中通过思维来验证板子硬件和程序能否完成我们想要的功能，一旦硬件做好了，做好板子回来剩下的就是靠编程来完成了。只要是硬件逻辑上没问题，功能上软件肯定可以实现。</p>
<p>当然了，我们在进行硬件电路设计的时候，也得充分考虑软件编程的方便性。因为我们的程序是用 P0 来控制点阵的整行，所以对于我们这样的电路设计，上下移动程序是比较好编写的。那如果我们设计电路的时候知道我们的图形要左右移动，那我们设计电路画板子的时候就要尽可能的把点阵横过来放，有利于我们编程方便，减少软件工作量。</p>
<p><strong>方法二、利用二维数组来实现，算法基本上和上下移动相似。</strong></p>
<p>二维数组，前边提过一次，他的使用其实也没什么复杂的。它的声明方式是：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">数据类型 数组名[数组长度 1][数组长度 2];</span><br></pre></td></tr></table></figure>
<p>与一位数组类似，数据类型是全体元素的数据类型，数组名是标识符，数组长度 1 和数组长度 2 分别代表数组具有的行数和列数。数组元素的下标一律从 0 开始。</p>
<p>例如：unsigned char a[2][3];声明了一个具有 2 行 3 列的无符号字符型的二维数组 a。</p>
<p>二维数组的数组元素总个数是两个长度的乘积。二维数组在内存中存储的时候，采用行优先的方式来存储，即在内存中先存放第 0 行的元素，再存放第一行的元素……，同一行中再按照列顺序存放，刚才定义的那个 a[2][3]的存放形式就如表 7-1 所示。</p>
<p><strong>表7-1 二维数组的物理存储结构</strong></p>
<table><tbody><tr><td>a[0][0]</td><td>a[0][1]</td><td>a[0][2]</td><td>a[1][0]</td><td>a[1][1]</td><td>a[1][2]</td></tr></tbody></table>

<p>二维数组的初始化方法分两种情况，我们前边学一维数组的时候学过，数组元素的数量可以小于数组元素个数，没有赋值的会自动给 0。当数组元素的数量等于数组个数的时候，如下所示：</p>
<p>unsigned char a[2][3] = &#123;&#123;1,2,3}, {4,5,6&#125;&#125;;</p>
<p>或者是</p>
<p>unsigned char a[2][3] = {1,2,3,4,5,6};</p>
<p>当数组元素的数量小于数组个数的时候，如下所示：</p>
<p>unsigned char a[2][3] = &#123;&#123;1,2}, {3,4&#125;&#125;;</p>
<p>等价于</p>
<p>unsigned char a[2][3] = {1,2,0,3,4,0};</p>
<p>而反过来的写法</p>
<p>unsigned char a[2][3] = {1,2,3,4};</p>
<p>等价于</p>
<p>unsigned char a[2][3] = &#123;&#123;1,2,3}, {4,0,0&#125;&#125;;</p>
<p>此外，二维数组初始化的时候，行数可以省略，编译系统会自动根据列数计算出行数，但是列数不能省略。</p>
<p>讲这些，只是为了让大家了解一下，看别人写的代码的时候别发懵就行了，但是我们今后写程序的时候，按照规范，行数列数都不要省略，全部写齐，初始化的时候，全部写成unsigned char a[2][3] = &#123;&#123;1,2,3}, {4,5,6&#125;&#125;;的形式，而不允许写成一维数组的格式，防止大家出错，同时也是提高程序的可读性。</p>
<p>那么下面我们要进行横向做 I ❤ U 的动画了，先把我们需要的图片画出来，再逐一取模，和上一张图片类似的是，我们这个图形共有 30 张图片，通过程序每 250ms 改变一张图片，就可以做出来动画效果了。但是不同的是，我们这个是要横向移动，横向移动的图片切换时的字模数据不是连续的，所以这次我们要对 30 张图片分别取模，如图 7-11 所示。</p>
<p><img src="http://c.biancheng.net/cpp/uploads/allimg/140317/1-14031F13303M5.png" alt></p>
<center><strong>图 7-11  横向动画取模图片</strong></center>

<p>图 7-11 中最上面的图形是横向连在一起的效果，而实际上我们要把它分解为 30 个帧，每帧图片单独取模，取出来都是 8 个字节的数据，一共就是 30*8 个数据，我们用一个二维数组来存储它们。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br></pre></td><td class="code"><pre><span class="line">#include &lt;reg52.h&gt;</span><br><span class="line">sbit ADDR0 = P1^0;</span><br><span class="line">sbit ADDR1 = P1^1;</span><br><span class="line">sbit ADDR2 = P1^2;</span><br><span class="line">sbit ADDR3 = P1^3;</span><br><span class="line">sbit ENLED = P1^4;</span><br><span class="line">unsigned char code image[30][8] = &#123;</span><br><span class="line">    &#123;0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF&#125;, //动画帧 1</span><br><span class="line">    &#123;0xFF,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F&#125;, //动画帧 2</span><br><span class="line">    &#123;0xFF,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F&#125;, //动画帧 3</span><br><span class="line">    &#123;0xFF,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F&#125;, //动画帧 4</span><br><span class="line">    &#123;0xFF,0x0F,0x9F,0x9F,0x9F,0x9F,0x9F,0x0F&#125;, //动画帧 5</span><br><span class="line">    &#123;0xFF,0x87,0xCF,0xCF,0xCF,0xCF,0xCF,0x87&#125;, //动画帧 6</span><br><span class="line">    &#123;0xFF,0xC3,0xE7,0xE7,0xE7,0xE7,0xE7,0xC3&#125;, //动画帧 7</span><br><span class="line">    &#123;0xFF,0xE1,0x73,0x73,0x73,0xF3,0xF3,0xE1&#125;, //动画帧 8</span><br><span class="line">    &#123;0xFF,0x70,0x39,0x39,0x39,0x79,0xF9,0xF0&#125;, //动画帧 9</span><br><span class="line">    &#123;0xFF,0x38,0x1C,0x1C,0x1C,0x3C,0x7C,0xF8&#125;, //动画帧 10</span><br><span class="line">    &#123;0xFF,0x9C,0x0E,0x0E,0x0E,0x1E,0x3E,0x7C&#125;, //动画帧 11</span><br><span class="line">    &#123;0xFF,0xCE,0x07,0x07,0x07,0x0F,0x1F,0x3E&#125;, //动画帧 12</span><br><span class="line">    &#123;0xFF,0x67,0x03,0x03,0x03,0x07,0x0F,0x9F&#125;, //动画帧 13</span><br><span class="line">    &#123;0xFF,0x33,0x01,0x01,0x01,0x03,0x87,0xCF&#125;, //动画帧 14</span><br><span class="line">    &#123;0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7&#125;, //动画帧 15</span><br><span class="line">    &#123;0xFF,0xCC,0x80,0x80,0x80,0xC0,0xE1,0xF3&#125;, //动画帧 16</span><br><span class="line">    &#123;0xFF,0xE6,0xC0,0xC0,0xC0,0xE0,0xF0,0xF9&#125;, //动画帧 17</span><br><span class="line">    &#123;0xFF,0x73,0x60,0x60,0x60,0x70,0x78,0xFC&#125;, //动画帧 18</span><br><span class="line">    &#123;0xFF,0x39,0x30,0x30,0x30,0x38,0x3C,0x7E&#125;, //动画帧 19</span><br><span class="line">    &#123;0xFF,0x9C,0x98,0x98,0x98,0x9C,0x1E,0x3F&#125;, //动画帧 20</span><br><span class="line">    &#123;0xFF,0xCE,0xCC,0xCC,0xCC,0xCE,0x0F,0x1F&#125;, //动画帧 21</span><br><span class="line">    &#123;0xFF,0x67,0x66,0x66,0x66,0x67,0x07,0x0F&#125;, //动画帧 22</span><br><span class="line">    &#123;0xFF,0x33,0x33,0x33,0x33,0x33,0x03,0x87&#125;, //动画帧 23</span><br><span class="line">    &#123;0xFF,0x99,0x99,0x99,0x99,0x99,0x81,0xC3&#125;, //动画帧 24</span><br><span class="line">    &#123;0xFF,0xCC,0xCC,0xCC,0xCC,0xCC,0xC0,0xE1&#125;, //动画帧 25</span><br><span class="line">    &#123;0xFF,0xE6,0xE6,0xE6,0xE6,0xE6,0xE0,0xF0&#125;, //动画帧 26</span><br><span class="line">    &#123;0xFF,0xF3,0xF3,0xF3,0xF3,0xF3,0xF0,0xF8&#125;, //动画帧 27</span><br><span class="line">    &#123;0xFF,0xF9,0xF9,0xF9,0xF9,0xF9,0xF8,0xFC&#125;, //动画帧 28</span><br><span class="line">    &#123;0xFF,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFE&#125;, //动画帧 29</span><br><span class="line">    &#123;0xFF,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF&#125; //动画帧 30</span><br><span class="line">&#125;;</span><br><span class="line">void main()&#123;</span><br><span class="line">    EA = 1;  //使能总中断</span><br><span class="line">    ENLED = 0;  //使能 U4，选择 LED 点阵</span><br><span class="line">    ADDR3 = 0;</span><br><span class="line">    TMOD = 0x01; //设置 T0 为模式 1</span><br><span class="line">    TH0 = 0xFC; //为 T0 赋初值 0xFC67，定时 1ms</span><br><span class="line">    TL0 = 0x67;</span><br><span class="line">    ET0 = 1;  //使能 T0 中断</span><br><span class="line">    TR0 = 1;  //启动 T0</span><br><span class="line">    while (1);</span><br><span class="line">&#125;</span><br><span class="line">/* 定时器 0 中断服务函数 */</span><br><span class="line">void InterruptTimer0() interrupt 1&#123;</span><br><span class="line">    static unsigned char i = 0; //动态扫描的索引</span><br><span class="line">    static unsigned char tmr = 0; //250ms 软件定时器</span><br><span class="line">    static unsigned char index = 0; //图片刷新索引</span><br><span class="line">    TH0 = 0xFC; //重新加载初值</span><br><span class="line">    TL0 = 0x67;</span><br><span class="line">    //以下代码完成 LED 点阵动态扫描刷新</span><br><span class="line">    P0 = 0xFF;  //显示消隐</span><br><span class="line">   </span><br><span class="line">    switch (i)&#123;</span><br><span class="line">        case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=image[index][0]; break;</span><br><span class="line">        case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=image[index][1]; break;</span><br><span class="line">        case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=image[index][2]; break;</span><br><span class="line">        case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=image[index][3]; break;</span><br><span class="line">        case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=image[index][4]; break;</span><br><span class="line">        case 5: ADDR2=1; ADDR1=0; ADDR0=1; i++; P0=image[index][5]; break;</span><br><span class="line">        case 6: ADDR2=1; ADDR1=1; ADDR0=0; i++; P0=image[index][6]; break;</span><br><span class="line">        case 7: ADDR2=1; ADDR1=1; ADDR0=1; i=0; P0=image[index][7]; break;</span><br><span class="line">        default: break;</span><br><span class="line">    &#125;</span><br><span class="line">    //以下代码完成每 250ms 改变一帧图像</span><br><span class="line">    tmr++;</span><br><span class="line">    if (tmr &gt;= 250)&#123; //达到 250ms 时改变一次图片索引</span><br><span class="line">        tmr = 0;</span><br><span class="line">        index++;</span><br><span class="line">        if (index &gt;= 30)&#123; //图片索引达到 30 后归零</span><br><span class="line">           index = 0;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>下载进到板子上瞧瞧，是不是有一种帅到掉渣的感觉呢。技术这东西，外行人看的是很神秘的，其实我们做出来会发现，也就是那么回事而已，每 250ms 更改一张图片，每 1ms在定时器中断里刷新单张图片的某一行。</p>
<p>不管是上下移动还是左右移动，大家要建立一种概念，就是我们是对一帧帧的图片的切换，这种切换带给我们的视觉效果就是一种动态的了。比如我们的 DV 拍摄动画，实际上就是快速的拍摄了一帧帧的图片，然后对这些图片的快速回放，把动画效果给显示了出来。因为我们硬件设计的缘故，所以在写上下移动程序的时候，数组定义的元素比较少，但是实际上大家也得理解成是 32 张图片的切换显示，而并非是真正的“移动”。</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/limh/tags/教程/" rel="tag"># 教程</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/limh/2014/12/01/mcu046/" rel="next" title="7.5、LED点阵的纵向移动">
                <i class="fa fa-chevron-left"></i> 7.5、LED点阵的纵向移动
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/limh/2014/12/01/mcu048/" rel="prev" title="8.1、单片机最小系统解析">
                8.1、单片机最小系统解析 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="SOHUCS"></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/limh/images/avatar.jpg" alt="土逗牛肉">
            
              <p class="site-author-name" itemprop="name">土逗牛肉</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/limh/archives/">
              
                  <span class="site-state-item-count">255</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/limh/categories/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/limh/tags/index.html">
                  <span class="site-state-item-count">7</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/limhGeek" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:1591054297@qq.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.jianshu.com/u/f73b243e7cc9" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-user-circle-o"></i>简书</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">土逗牛肉</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
	var str = GetUrlParam('height');
    if (str === '0'){
		document.getElementById('header').style.display = 'none';
		document.getElementById('comments').style.display = 'none';
		document.getElementById('footer').style.display = 'none';
		document.getElementsByClassName('post-footer').item(0).style.display = 'none'
	}
	
    function GetUrlParam(paraName) {
        var url = document.location.toString();
        var arrObj = url.split("?");

        if (arrObj.length > 1) {
            var arrPara = arrObj[1].split("&");
            var arr;

            for (var i = 0; i < arrPara.length; i++) {
                 arr = arrPara[i].split("=");

                if (arr != null && arr[0] === paraName) {
                    return arr[1];
                }
            }
            return "";
        } else {
            return "";
        }
    }
</script>









  












  
  
    <script type="text/javascript" src="/limh/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/limh/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/limh/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/limh/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/limh/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/limh/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/limh/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/limh/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
